//@charset "utf-8"
/*限制字数*/
function mCutStr(str, len, str2) {
    
    if (str2 == '') {
        var str3 = '';
    } else {
        var str3 = str2 || '...';
    }
    if (str == '') {
        return '';
    }else{
        var str_length = 0; //实际长度
        var str_len = 0;
        str_cut = new String();
        str_len = str.length;
        for (var i = 0; i < str_len; i++) {
            
            var a = str.charAt(i);
            str_length++;
            //中文的情况多加1
            if (escape(a).length > 4) {
                //中文字符的长度经编码之后大于4
                str_length++;
            }
            str_cut = str_cut.concat(a);
            if (str_length <= len && (i == (str_len - 1) || i == (str_len - 2))) {
                return str;
            }
            if (str_length >= len && i < (str_len - 2)) {
                str_cut = str_cut.concat(str3);
                return str_cut;
            }
            if (str_length >= len && i < (str_len - 1)) {
                str_cut = str_cut.concat(str3);
                return str_cut;
            }
        }
    }
}
/*只能输入数字和小数点*/
function clearNoNum(obj){
	//先把非数字的都替换掉，除了数字和点(.)
	obj.value = obj.value.replace(/[^\d.]/g,"");
	//必须保证第一个为数字而不是点(.)
	obj.value = obj.value.replace(/^\./g,"");
	//保证只有出现一个点而没有多个点
	obj.value = obj.value.replace(/\.{2,}/g,".");
	//保证点只出现一次，而不能出现两次以上
	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
}
/*点击关闭和取消，关闭当前自己的主窗口*/
$(".hd-close, .cancel, #way_sure").on('click',function(){
	$(this).parent().parent().hide();
	if($(".mask").css("display") != "block"){
		$(".mask").show();
	}else{
		$(".mask").hide();
	}
});
//点击取消统计
$("#cancelPro").click(function(){
    var external = new ThsExternal();
external.closeWindow();
    TaNumber.cancelPro();
});
/*是否显示预警声音*/
$('.sound').live('click',function(){
    var sounds = $(".sound").find(".c-on");
    if(sounds.css("display") != "inline-block"){
        $("#soundid").hide();
    }else{
        $("#soundid").show();
    }
});
//按键精灵中的input下的提示
function weiNull() {
    if($("#view_stock_input").val() == ''){
        $('.tip-stock').show();
    } else {
    	$('.tip-stock').hide();
    }
}
//获取location.url中的某一个字段值
function getUrlParam(item) {
    var value = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i"));
    return value ? value[1] : value;
}

/**
 * 选定股票的绑定事件
 * @param string stock 股票代码
 */
async function selectedFn(stock) {
	$('#view_stock_input').blur();
	//await hqQuote.request(condition.render, stock, '');
}
//时间戳转换成 01-02 20：10
function userDate(uData){
    var myDate = new Date(uData*1000);
    var nowDate = new Date();
    var nMonth = nowDate.getMonth() + 1;
    var nDay = nowDate.getDate();
    var year = myDate.getFullYear();
    var month = myDate.getMonth() + 1;
    var day = myDate.getDate();
    var hours = myDate.getHours();
    var minutes = myDate.getMinutes();
    if(nMonth == month && nDay == day){
        if(hours < 10){
            hours = '0'+hours;
        }
        if(minutes < 10){
            minutes = '0' +minutes;
        }
        return '今天' + ' ' + hours + ':' + minutes;
    }else{
        if(month < 10){
            month = '0'+month;
        }
        if(day < 10){
            day = '0'+day;
        }
        if(hours < 10){
            hours = '0'+hours;
        }
        if(minutes < 10){
            minutes = '0' +minutes;
        }
        return month + '-' + day + ' ' + hours + ':' + minutes;
    }
    
}
//闪动
var shake = function(element,className,times){
    var i = 0,
        t = false,
        o = element.attr('class'),
        c = "",
        times = times || 2;
    if(t) return;
    t = setInterval(function(){
        i++;
        c = i%2 ? o + ' ' + className : o;
        element.attr('class',c);
        if(i==2*times){
            clearInterval(t);
            element.removeCless(className);
        }
    }, 100);
}
Array.prototype.delNull = function (from, to) {
    from = from || '';
    to = to || null;
    var arr = this;
    var len = arr.length
    for (var i = 0; i < len; i++) {
        if (arr[i] == from) {
           // arr.splice(i, 1);
            if (to == null) {
                arr.splice(i, 1);
            } else {
                arr.splice(i, 1, to);
            }
        }
    }
    return arr;
}
function modeAdd(){
    var mode = new Array();
    mode.push($("#keep_monitor").hasClass("c-on") ? 1 : 0);
    mode.push($("#show_pop").hasClass("c-on") ? 1 : 0);
    //mode.push(1);
    if ($("#show_sounds").hasClass("c-on")) {
        mode.push(1);
        mode.push(1);
        mode.push($("#soundid").val());
    } else {
        mode.push(0);
        mode.push(1);
    }
    mode.push($("#keep_iphone").hasClass("c-on") ? 1 : 0);
    mode = mode.join(',');
}
//点击通知到手机
$(".spread, #call_appid").click(async function(){
    TaNumber.spreadId();
    var util = new ThsUtil();
    await util.openAppWebDlg('http://sp.10jqka.com.cn/sms/downloadapp/');
  //  var appendHtml = "<iframe name='iframepage' src='captcha/index.html' frameborder= '0' width='100%' height='100%'></iframe>";
    /*$("#box").show();
    $(".mask").show();
    $(".mobile1").val('输入手机号');
    $(".yzm").val("输入验证码");
    $(".mobile1, .yzm").css('color',"#a2a2a2");
    $(".yzmtipok").hide();
    $(".tipok").hide();
    $(".tips").hide();*/
    /*if($("#box").html().length < 192){
        $("#box").append(appendHtml);
    }*/
});
